<!--
Handles the personal account settings of a teacher.

@author Michael Argarin
@author Chad Estioco
@version Second Semester, AY 2010-2011
-->
<?php include("fetchData.php"); ?>
<?php $data=fetchAccountDetails();?>
<script type="text/javascript" language="javascript">
	
	/**
	Idea: Can I use this for The Chad Estioco Framework?
	*/
	function verifyPassword(){
		var new_password = document.getElementById("newpass")
		var retyped = document.getElementById("renewpass")
		if(new_password.value == retyped.value){
			document.getElementById("f").submit()
		} else{
			alert("New password was retyped incorrectly.")
			retyped.select()
		}
	}

</script>
            <table class="pMirror">
            	<form name="profileSheet" id="f" action="editProfile.php" method="post">
				<input type="text" style="display: none;" name="toggle" value="set" />
				<tr><td colspan="2"><div class="form_section"><h1>Personal Info</h1></div></td></tr>
                <tr><td colspan="2"><span style="font-size:11px;">NOTE: Fields marked with an asterisk (*) are REQUIRED.</span></td></tr>
                <tr><td colspan="2"><span style="font-size:11px;">Failure to provide any input on such fields would NOT remove nor change their previous values.</span></td></tr>
                <tr>
                	<td>First Name</td>
                    <td><input name="fname" type="text" value="<?php echo $data['first_name']; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Middle Name</td>
                    <td><input name="mname" type="text" value="<?php echo $data["middle_name"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Last Name</td>
                    <td><input name="lname" type="text" value="<?php echo $data["last_name"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Gender</td>
                    <td><select name="sex">
                    	<?php if($data["sex"]=='M'){?>
                    		<option selected value="M">male</option>
                            <option value="F">female</option>
                        <?php }else{?>
                        	<option value="M">male</option>
                        	<option selected value="F">female</option>
                         <?php }?>
                        </select>
				   	</td>
                </tr>
                <tr>
                	<td>Birthday</td>
                    <td>
						<select id="years" name="years"></select>
						<select id="months" name="months" onchange="showDates()"></select>
						<select id="dates" name="dates"></select>
						<?php
						echo "<script type='text/javascript' language='javascript'>";
						echo "var defaultMonth = " . (date('n',strtotime($data["birthday"])) - 1) . "\n";
						echo "var defaultYear = " . date('Y',strtotime($data["birthday"])) . "\n";
						echo "var defaultDate = ". date('j',strtotime($data["birthday"])) . "\n";
						echo "</script>";
						?>
						<script type="text/javascript" language="javascript" src="../boilerplate/js/birthday.js"></script>
				   	</td>
                </tr>
                <tr>
                	<td>Country</td>
                    <td><input name="country" type="text" value="<?php echo $data["country"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>City</td>
                    <td><input name="city" type="text" value="<?php echo $data["city_province"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Municipality</td>
                    <td><input name="municipality" type="text" value="<?php echo $data["municipality"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Street</td>
                    <td><input name="street" type="text" value="<?php echo $data["street"]; ?>" style="width:100%"></td>
                </tr>
                <tr><td colspan="2"><div class="form_section"><h1>Contact Information</h1></div></td></tr>
                <tr>
                	<td>E-mail*</td>
                    <td><input name="email" type="text" value="<?php echo $data["email"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Contact Number</td>
                    <td><input name="num" type="text" value="<?php echo $data["contact_number"]; ?>" style="width:100%"></td>
                </tr>
                <tr><td colspan="2"><div class="form_section"><h1>Change Password</h1></div></td></tr>
                <tr>
                	<td>Password</td>
                    <td><input name="pwd" type="password" id="password" style="width:100%"></td>
                </tr>
				<tr>
                	<td>New Password</td>
                    <td><input name="npwd" type="password" id="newpass" style="width:100%"></td>
                </tr>
				<tr>
                	<td>Retype New Password</td>
                    <td><input name="rnpwd" type="password" id="renewpass" style="width:100%"></td>
                </tr>
            	<tr><td colspan="2" align="right"><input type="button" onclick="verifyPassword()" name="update" value="Update Account"></td></tr>
                </form>
            </table>
			</div>